import { http } from '@/utils/http.ts'
import type { CartItem } from '@/types/cart'

export const getCartListApi = () => {
  return http<CartItem[]>({
    method: 'GET',
    url: '/member/cart',
  })
}

export const delCartApi = (data: { ids: string[] }) => {
  return http({
    method: 'DELETE',
    url: '/member/cart',
    data,
  })
}

export const updateCartApi = (skuId: string, data: { selected?: boolean; count?: number }) => {
  return http({
    method: 'PUT',
    url: `/member/cart/${skuId}`,
    data,
  })
}

export const changeSelectedAllApi = (data: { selected: boolean }) => {
  return http({
    method: 'PUT',
    url: `/member/cart/selected`,
    data,
  })
}
